﻿<UserControl x:Class="LiveS3D.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:Core="clr-namespace:Microsoft.SilverlightMediaFramework.Core;assembly=Microsoft.SilverlightMediaFramework.Core" 
    xmlns:Media="clr-namespace:Microsoft.SilverlightMediaFramework.Core.Media;assembly=Microsoft.SilverlightMediaFramework.Core" 
    xmlns:plugins3d="clr-namespace:Microsoft.SilverlightMediaFramework.Plugins.Primitives.S3D;assembly=Microsoft.SilverlightMediaFramework.Plugins"
    xmlns:vsm="clr-namespace:System.Windows;assembly=System.Windows"
    mc:Ignorable="d"
    d:DesignHeight="300" d:DesignWidth="400">


    <Grid x:Name="LayoutRoot" Background="Black">

        <vsm:VisualStateManager.VisualStateGroups>
            <vsm:VisualStateGroup x:Name="SettingStates">
                <vsm:VisualState x:Name="SettingsVisible">
                    <Storyboard>
                        <ObjectAnimationUsingKeyFrames Duration="0:0:0" Storyboard.TargetName="SettingsPanel" Storyboard.TargetProperty="Visibility">
                            <DiscreteObjectKeyFrame KeyTime="0:0:0" Value="Visible" />
                        </ObjectAnimationUsingKeyFrames>
                        <DoubleAnimation Duration="0:0:0.5" Storyboard.TargetName="SettingsPanel" Storyboard.TargetProperty="Opacity" To="1">
                            <DoubleAnimation.EasingFunction>
                                <CubicEase EasingMode="EaseInOut" />
                            </DoubleAnimation.EasingFunction>
                        </DoubleAnimation>
                        <DoubleAnimation Duration="0:0:0.5" Storyboard.TargetName="SettingsScaler" Storyboard.TargetProperty="ScaleX" To="1">
                            <DoubleAnimation.EasingFunction>
                                <CubicEase EasingMode="EaseInOut" />
                            </DoubleAnimation.EasingFunction>
                        </DoubleAnimation>
                        <DoubleAnimation Duration="0:0:0.5" Storyboard.TargetName="SettingsScaler" Storyboard.TargetProperty="ScaleY" To="1">
                            <DoubleAnimation.EasingFunction>
                                <CubicEase EasingMode="EaseInOut" />
                            </DoubleAnimation.EasingFunction>
                        </DoubleAnimation>
                    </Storyboard>
                </vsm:VisualState>
                <vsm:VisualState x:Name="SettingsHidden">
                    <Storyboard>
                        <ObjectAnimationUsingKeyFrames Duration="0:0:0.5" Storyboard.TargetName="SettingsPanel" Storyboard.TargetProperty="Visibility">
                            <DiscreteObjectKeyFrame KeyTime="0:0:0.5" Value="Collapsed" />
                        </ObjectAnimationUsingKeyFrames>
                        <DoubleAnimation Duration="0:0:0.5" Storyboard.TargetName="SettingsPanel" Storyboard.TargetProperty="Opacity" To="0">
                            <DoubleAnimation.EasingFunction>
                                <CubicEase EasingMode="EaseInOut" />
                            </DoubleAnimation.EasingFunction>
                        </DoubleAnimation>
                        <DoubleAnimation Duration="0:0:0.5" Storyboard.TargetName="SettingsScaler" Storyboard.TargetProperty="ScaleX" To="0">
                            <DoubleAnimation.EasingFunction>
                                <CubicEase EasingMode="EaseInOut" />
                            </DoubleAnimation.EasingFunction>
                        </DoubleAnimation>
                        <DoubleAnimation Duration="0:0:0.5" Storyboard.TargetName="SettingsScaler" Storyboard.TargetProperty="ScaleY" To="0">
                            <DoubleAnimation.EasingFunction>
                                <CubicEase EasingMode="EaseInOut" />
                            </DoubleAnimation.EasingFunction>
                        </DoubleAnimation>
                    </Storyboard>
                </vsm:VisualState>
            </vsm:VisualStateGroup>
        </vsm:VisualStateManager.VisualStateGroups>

        <Core:SMFPlayer x:Name="smf" AutoPlay="True">
            <!--<Core:SMFPlayer.Playlist>
                <Media:PlaylistItem MediaSource="webcam://fake" DeliveryMethod="NotSpecified">
                    <Media:PlaylistItem.S3DProperties>
                        <plugins3d:S3DProperties S3DEyePriority="LeftFirst" S3DFormat="SideBySide" S3DContent="Pair" S3DLeftEyePAR="1.0" S3DRightEyePAR="1.0" />
                    </Media:PlaylistItem.S3DProperties>
                </Media:PlaylistItem>
            </Core:SMFPlayer.Playlist>-->
        </Core:SMFPlayer>

        <Button HorizontalAlignment="Right" VerticalAlignment="Top" Click="ButtonSettings_Click">
            <Button.Template>
                <ControlTemplate TargetType="Button">
                    <Grid>
                        <vsm:VisualStateManager.VisualStateGroups>
                            <vsm:VisualStateGroup x:Name="CommonStates" >
                                <vsm:VisualState x:Name="Normal" />
                                <vsm:VisualState x:Name="MouseOver">
                                    <Storyboard>
                                        <DoubleAnimation Duration="0" Storyboard.TargetName="contentPresenter" Storyboard.TargetProperty="Opacity" To=".55" />
                                    </Storyboard>
                                </vsm:VisualState>
                                <vsm:VisualState x:Name="Pressed">
                                    <Storyboard>
                                        <DoubleAnimation Duration="0" Storyboard.TargetName="contentPresenter" Storyboard.TargetProperty="Opacity" To="1" />
                                    </Storyboard>
                                </vsm:VisualState>
                                <vsm:VisualState x:Name="Disabled">
                                    <Storyboard>
                                        <DoubleAnimation Duration="0" Storyboard.TargetName="DisabledVisualElement" Storyboard.TargetProperty="Opacity" To=".55" />
                                    </Storyboard>
                                </vsm:VisualState>
                            </vsm:VisualStateGroup>
                            <vsm:VisualStateGroup x:Name="FocusStates" >
                                <vsm:VisualState x:Name="Focused" />
                                <vsm:VisualState x:Name="Unfocused" />
                            </vsm:VisualStateGroup>
                        </vsm:VisualStateManager.VisualStateGroups>
                        <ContentPresenter x:Name="contentPresenter" Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" Opacity="0" />
                        <Rectangle x:Name="DisabledVisualElement" RadiusX="3" RadiusY="3" Fill="#FFFFFFFF" Opacity="0" IsHitTestVisible="false"  />
                    </Grid>
                </ControlTemplate>
            </Button.Template>

            <Image Source="/Resources/settings.png" Stretch="None" />
        </Button>

        <Border x:Name="SettingsPanel" Margin="3,3,3,42" RenderTransformOrigin="1,0" VerticalAlignment="Top" HorizontalAlignment="Right" Opacity="0" Visibility="Collapsed" Background="#44000000" CornerRadius="6" BorderThickness="1" BorderBrush="#44FFFFFF">
            <Border.RenderTransform>
                <ScaleTransform x:Name="SettingsScaler" ScaleX="0" ScaleY="0" />
            </Border.RenderTransform>
            <Grid Margin="3">
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="*" />
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="*" />
                    <ColumnDefinition Width="Auto" />
                </Grid.ColumnDefinitions>
                <TextBlock Foreground="White" FontWeight="Bold" Text="3D Plugins" HorizontalAlignment="Center" Margin="3,3,3,0" VerticalAlignment="Center" />
                <HyperlinkButton Foreground="White" FontWeight="Bold" Content="X" VerticalAlignment="Center" Click="ButtonClose_Click" Margin="3,3,3,0" Grid.Column="1" />
                <StackPanel Grid.Row="1" Grid.ColumnSpan="2" Margin="3">
                    <RadioButton Foreground="White" x:Name="AnaglyphButton" Content="Anaglyph" Checked="Anaglyph_Checked" IsChecked="True" />
                    <RadioButton Foreground="White" x:Name="NVidiaButton" Content="NVidia 3D" Checked="NVidia_Checked" IsChecked="False" />
                    <RadioButton Foreground="White" x:Name="NoneButton" Content="None" Checked="None_Checked" IsChecked="False" />
                </StackPanel>
            </Grid>
        </Border>

        <Grid x:Name="StupidStartButton" Background="#bb000000">
            <HyperlinkButton FontSize="33" Foreground="White" Click="Button_Click" Content="Click to start" HorizontalAlignment="Center" VerticalAlignment="Center" />
        </Grid>

        <Grid x:Name="ErrorMessage" Visibility="Collapsed">
            <Grid.Background>
                <SolidColorBrush Color="#66000000" />
            </Grid.Background>
            <TextBlock Text="Sorry, you need 2 webcams for the demo to work." TextWrapping="Wrap" TextAlignment="Center" FontSize="24" Foreground="#BBFFFFFF" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="24" />
        </Grid>
        <Grid x:Name="WarningMessage" Visibility="Collapsed" IsHitTestVisible="False">
            <TextBlock Text="Sorry, you need 2 webcams to see this demo in 3D." TextWrapping="Wrap" TextAlignment="Center" FontSize="24" Foreground="#BBFFFFFF" HorizontalAlignment="Center" VerticalAlignment="Top" Margin="24" />
        </Grid>
    </Grid>
</UserControl>
